package miko.mikoplex;

import com.jme3.input.controls.AnalogListener;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;

public class AnalogCamMover implements AnalogListener {
	final private Camera cam;
	final private float moveXratio;
	final private float moveZratio;
	final private float moveYratio;
	
	public AnalogCamMover(Camera cam,float[] ratios) {
		if (ratios.length >= 1) moveXratio = ratios[0];
		else moveXratio = 0f;
		if (ratios.length >= 2) moveYratio = ratios[1];
		else moveYratio = 0f;
		if (ratios.length >= 3) moveZratio = ratios[2];
		else moveZratio = 0f;
		this.cam = cam;
	}

	@Override
	public void onAnalog(String name, float value, float tpf) {
		Vector3f v = cam.getLocation();
		v.x += value*moveXratio;
		v.y += value*moveYratio;
		v.z += value*moveZratio;
		cam.setLocation(v);
	}

}
